import Person from "@/components/Person";
import Search from "@/components/Search";
import Sheet from "@/components/Sheet";
import { Card, Space } from "antd";
import dayjs from "dayjs";
import { useState } from "react";
import { useDispatch } from "react-redux";
import { setShowBtnTool } from "@/store/modules/style";
import BtnTool from "@/components/BtnTool";
const columns = [
    {
        title: '二级单位',
        dataIndex: 'content',
    },
    {
        title: '社区成员数量',
        dataIndex: 'type'
    },
    {
        title: '网红企业',
        dataIndex: 'creator'
    },
    {
        title: '权重占比',
        dataIndex: 'time',
    },
    {
        title: '模型',
        dataIndex: 'moxing',
    }
]
const dataSource = {
    total: 20,
    data: Array.from({
        length: 46,
    }).map((_, i) => ({
        key: i,
        content: '一院',
        type: `1${i}`,
        creator: 'XXX有限公司',
        time:'30%',
        moxing:'Louvain算法'
    }))
};
export default function Shequpaiming() {
    const [page, setPage] = useState({ pageNum: 1, pageSize: 10 })
    const [selectedRowKeys, setSelectedRowKeys] = useState([]);
    const dispatch = useDispatch()
    const handleSearch = (val) => {
        console.log(val)
    }
    // 分页
    const handlePage = (pageNum, pageSize) => {
        setPage({
            pageNum,
            pageSize
        })
    }
    // 表格选择
    const handleSelChange = (selectedRowKeys, selectedRows) => {
        setSelectedRowKeys(selectedRowKeys)
        dispatch(setShowBtnTool(selectedRowKeys.length > 0))
    }
    const rowSelection = {
        selectedRowKeys,
        onChange: handleSelChange,
    };
    const handleDel = () => {
        // 删除接口
        console.log('删除')
    }
    return (
        <div>
            <h2 className="headline">社区排名</h2>
            <Space direction="vertical" size={16} style={{ width: "100%" }}>
                <Search onSearch={handleSearch} isShequ></Search>
                <Card>
                    <Sheet columns={columns} dataSource={dataSource} rowSelection={rowSelection} rowKey='key' page={page} onChange={handlePage}></Sheet>
                </Card>
            </Space>
            {<BtnTool total={`已选择 ${selectedRowKeys.length} 项`} isShow={selectedRowKeys.length > 0} isSave={false} onDel={handleDel}></BtnTool>}
        </div>
    )
}